var common = require('../../../utils/common.js');
var app = getApp()
Page({
    data: {
        __PUBLIC__:app.__PUBLIC__ ,      
    },
    onLoad: function (options) {
        common.bestCurl('GET','/admin/detail',res=>{
            if(res.statusCode == 200){
                if(res.data.code==2){
                    console.log(res.data)
                }else{
                    this.setData({details:res.data})    
                }
            }
        },{'id':options.id})
    },
    delete:function(event){
        id = event.currentTarget.id;
        wx.showModal({
            title: '确认要删除吗?',
            cancelText: "取消",
            confirmText: "确定",
            success: function (res) {
                if (res.confirm) {
                    common.bestCurl('GET','/admin/delete',res=>{
                        if(res.statusCode == 200){
                            if(res.data.code == 1){
                                wx.showToast({
                                    title: '删除成功',
                                    icon: '',
                                    duration: 2000
                                });
                                setTimeout(res=>{
                                    wx.redirectTo({
                                        url: '../list/list'
                                    })

                                },2000)
                            }else if(res.data.code == 3){
                                wx.showToast({
                                    title: '删除失败,请解除绑定',
                                    icon: '',
                                    duration: 3000
                                });
                            }else{
                                console.log(res.data.msg)
                            }
                        }
                    },{'id':id})
                }else{
                    console.log('用户点击辅助操作')
                }
            }
        });
    }
})

